﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ipswitch
{
    public partial class Form_settings : Form
    {
        public IPConfig[] ipconfig = new IPConfig[2];
        public Form_settings()
        {
            InitializeComponent();
        }

        private void Form_settings_Load(object sender, EventArgs e)
        {
            ipconfig[0] = new IPConfig();
            ipconfig[0].ip = this.textBox_ip1.Text = ConfigHelper.Get("ip1");
            ipconfig[0].mask = this.textBox_mask1.Text = ConfigHelper.Get("mask1");
            ipconfig[0].gateway = this.textBox_gateway1.Text = ConfigHelper.Get("gateway1");

            ipconfig[1] = new IPConfig();
            ipconfig[1].ip = this.textBox_ip2.Text = ConfigHelper.Get("ip2");
            ipconfig[1].mask = this.textBox_mask2.Text = ConfigHelper.Get("mask2");
            ipconfig[1].gateway = this.textBox_gateway2.Text = ConfigHelper.Get("gateway2");
        }

        private void button_ok_Click(object sender, EventArgs e)
        {
            ConfigHelper.Set("ip1", this.textBox_ip1.Text);
            ConfigHelper.Set("mask1", this.textBox_mask1.Text);
            ConfigHelper.Set("gateway1", this.textBox_gateway1.Text);

            ConfigHelper.Set("ip2", this.textBox_ip2.Text);
            ConfigHelper.Set("mask2", this.textBox_mask2.Text);
            ConfigHelper.Set("gateway2", this.textBox_gateway2.Text);

            this.Dispose();
        }

        private void button_cancel_Click(object sender, EventArgs e)
        {
            this.Dispose();
        }
    }
}
